package com.cqie.hospitalescort.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

import com.cqie.hospitalescort.DTO.EscortDTO;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

/**
 * <p>
 * 陪诊人员表
 * </p>
 *
 * @author gdy
 * @since 2025-02-18
 */
@Getter
@Setter
@TableName("escort_info")
@ApiModel(value = "EscortInfo对象", description = "陪诊人员表")
public class EscortInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty("陪诊人姓名")
    private String name;

    @ApiModelProperty("性别（0为女，1为男）")
    private Integer sex;

    @ApiModelProperty("出生日期")
    private String age;

    @ApiModelProperty("联系电话")
    private String phone;

    @ApiModelProperty("身份证号")
    private String identityCard;

    @ApiModelProperty("详细地址")
    private String addressInfo;

    @ApiModelProperty("描述")
    @TableField(value = "content")
    private String description;

    @ApiModelProperty("陪诊员福利积分")
    @TableField(fill = FieldFill.INSERT)
    private Long score;

    @ApiModelProperty("隶属于的医院id")
    private Long hospitalId;

    @ApiModelProperty("陪诊员个性化图片url")
    @TableField(value = "escort_picture_url")
    private String picture;

    @ApiModelProperty("评价得分")
    private BigDecimal accessScore;

    @ApiModelProperty("状态(1-空闲，2-陪诊中，3-同时间已被预约，4-待审核)")
    private Integer escortStatus;

    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty("修改时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty("逻辑删除")
    @TableLogic
    private Integer deleteFlag;

    @ApiModelProperty("头像")
    @TableField(value = "avatar")
    private String avatar;

    @TableField(exist = false)
    private HospitalInfo hospitalInfo;

    public void buildEscortInfo(EscortDTO dto) {
        this.setId(dto.getId());
        this.setName(dto.getName());
        this.setSex(dto.getSex());
        this.setAge(dto.getAge());
        this.setPhone(dto.getPhone());
        this.setIdentityCard(dto.getIdentityCard());
        this.setAddressInfo(dto.getAddressInfo());
        this.setDescription(dto.getDescription());
        this.setHospitalId(dto.getHospitalId());
        this.setPicture(dto.getPicture());
        this.setAccessScore(BigDecimal.valueOf(0));
    }

    public EscortDTO buildEscortDTO(){
        EscortDTO dto = new EscortDTO();
        BeanUtils.copyProperties(this, dto);
        return dto;
    }


}
